home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16886 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  982 b 

  1. Path: news.jhu.edu!news
  2. From: yuehong@psi.ece.jhu.edu (yuehong)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Copy constructor
  5. Date: 12 Apr 1996 15:54:53 GMT
  6. Organization: The Johns Hopkins Univ.
  7. Message-ID: <4klucd$698@news.jhu.edu>
  8. References: <4kjudi$2qj0@holly.ACNS.ColoState.EDU>
  9. NNTP-Posting-Host: 128.220.62.157
  10. X-Newsreader: WinVN 0.92.6+
  11.  
  12. In article <4kjudi$2qj0@holly.ACNS.ColoState.EDU>, corbyh@holly.ACNS.ColoState.EDU (Corby S. Hudnall) says:
  13. >
  14. >Hi all, I'm having some trouble figuring out how to do a copy 
  15. >constructor.  Here's what I thought was suppose to work:
  16. >
  17. >header file----
  18. >class ABC
  19. >{
  20. >        private:
  21. >                int AnInt;
  22. >
  23. >        public:
  24. >                ABC():AnInt(5) {}  // Default Constructor
  25. >                ~ABC() {}          // Default Destructor
  26. >                ABC(const ABC&);   // Copy constructor
  27. >}     <---you missed ";" here.
  28.  
  29.  
  30.  
  31. >
  32. >ABC::ABC(const ABC& NewABC)
  33. >{
  34. >   this->AnInt = NewABC->AnInt;<----- NewABC is not a pointer.
  35. >}
  36. >
  37.